package com.example.es.myt;

import org.apache.http.HttpHost;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

public class ESTest_Client_Delete {
    public static void main(String[] args) throws IOException {
        //创建客户端
        RestHighLevelClient restHighLevelClient=new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200,"http"))
        );

        GetRequest request=new GetRequest();
        request.index("user").id("1001");

        GetResponse response = restHighLevelClient.get(request, RequestOptions.DEFAULT);


        System.out.println("索引操作"+response.getSourceAsString());

        //关闭
        restHighLevelClient.close();
    }
}
